package cate.game.play.proce.action.po;

import cate.common.util.XT;
import com.fasterxml.jackson.annotation.JsonIgnore;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;
import lombok.NoArgsConstructor;

import java.util.ArrayList;
import java.util.List;

@NoArgsConstructor
@NoteClass("技能释放数据")
public class SkillActionPO extends ActionPO {

	@NoteField("本次行动的模板id")
	public int tid;

	@NoteField("子技能的释放数据")
	public List<SkillActionPO> children;

	/** 追加子技能的行动数据 */
	public void addChild(SkillActionPO child) {
		if (this.children == null) {
			this.children = new ArrayList<>();
		}
		this.children.add(child);
	}

	@Override
	@JsonIgnore
	public boolean isEmpty() {
		if (!XT.isBlank(results)) {
			return false;
		} else {
			if (!XT.isBlank(children)) {
				for (SkillActionPO child : children) {
					if (!child.isEmpty()) {
						return false;
					}
				}
			}
			return true;
		}
	}
}
